package io.github.talelin.latticy.repository;

import io.github.talelin.latticy.entity.User;
import io.github.talelin.latticy.vo.TeamJobVO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface UserRepository extends JpaRepository<User, Long> {

    @Query(value = "select \n" +
            "u.id, u.nickname, u.avatar,\n" +
            "j.id as job_id, " +
            "j.user_id, j.project_id, j.title as job_title, j.create_time,\n" +
            "p.title as project_title, p.backgroud_color, p.color\n" +
            "from lin_user u \n" +
            "join job j on j.user_id = u.id\n" +
            "join project p on p.id = j.project_id\n" +
            "where u.id <> :id \n" +
            "and u.delete_time is null \n" +
            "and DATEDIFF(j.create_time, :now) = 0\n", nativeQuery = true)
    List<User> findOtherUserJob(Long id, String now);

    List<User> findByIdNot(Long id);

    List<User> findByIdIn(List<Long> userId);
}
